<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        for (var i = 1; i <= 10; i++) {
            if (i % 3 == 0) {
                console.warn('break');
                break;
            }
            console.log(i);
        }
    </script>
</body>

</html>

<!-- 使用break退出循环 -->
<!-- https://developer.mozilla.org/zh-CN/docs/Learn/JavaScript/Building_blocks/Looping_code -->

<!-- break -->
<!-- https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/break -->